package com.china08.yxyapi.repository.mg.mistakes;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;

import com.china08.yxyapi.entity.mg.mistakes.StuMistakesQues;

public interface StuMistakesQuesRepository extends MongoRepository<StuMistakesQues, String> {

    StuMistakesQues findById(String id);

    // 根据学生查询错题
    List<StuMistakesQues> findByStudentId(String studentIid);

    List<StuMistakesQues> findByStudentIdAndSubjectAndStatusAndFocusAndPublishDateBetween(String studentId,
            String subject, Integer status, Integer focus, Date startDate, Date endDate);

    // 错题数量
    Integer countByStudentIdAndSubjectAndStatusAndFocusAndPublishDateBetween(String studentId, String subject,
            Integer status, Integer focus, Date startDate, Date endDate);

    // 查询非其它学科错题
    Page<StuMistakesQues> findByStudentIdAndSubjectInAndStatusAndPublishDateBetween(String studentId,
            List<String> subjectLst, Integer status, Date startDate, Date endDate, Pageable pageable);

    // 查询其它学科错题
    Page<StuMistakesQues> findByStudentIdAndSubjectNotInAndStatusAndPublishDateBetween(String studentId,
            List<String> subjectNotLst, Integer status, Date startDate, Date endDate, Pageable pageable);

    // 根据学生id和错题id查错题
    StuMistakesQues findByQuesIdAndStudentId(String quesId, String studentId);

    /* 错题划分：全部 */
    Page<StuMistakesQues> findByStudentIdAndSubjectInAndStatusAndFocusAndPublishDateBetween(String studentId,
            List<String> subjectLst, Integer status, Integer focus, Date startDate, Date endDate, Pageable pageable);

    /* 错题划分：重点题 */
    Page<StuMistakesQues> findByStudentIdAndSubjectNotInAndStatusAndFocusAndPublishDateBetween(String studentId,
            List<String> subjectNotLst, Integer status, Integer focus, Date startDate, Date endDate, Pageable pageable);

    StuMistakesQues findTOP1ByQuesId(String quesId);

    /***************************************************************************/
    Page<StuMistakesQues> findByStudentIdAndSubjectInAndStatusAndQuestionTypeInAndPublishDateBetween(String studentId,
            List<String> subjectLst, Integer status, List<String> questionTypeLst, Date startDate, Date endDate,
            Pageable pageable);

    Page<StuMistakesQues> findByStudentIdAndSubjectNotInAndStatusAndQuestionTypeInAndPublishDateBetween(
            String studentId, List<String> gradeSubjectNotLst, Integer status, List<String> questionTypeLst,
            Date startDate, Date endDate, Pageable pageable);

    Page<StuMistakesQues> findByStudentIdAndSubjectInAndStatusAndQuestionTypeInAndFocusAndPublishDateBetween(
            String studentId, List<String> subjectLst, Integer status, List<String> questionTypeLst, Integer focus,
            Date startDate, Date endDate, Pageable pageable);

    Page<StuMistakesQues> findByStudentIdAndSubjectNotInAndStatusAndQuestionTypeInAndFocusAndPublishDateBetween(
            String studentId, List<String> gradeSubjectNotLst, Integer status, List<String> questionTypeLst,
            Integer focus, Date startDate, Date endDate, Pageable pageable);

}
